
use processed/RPImicro,clear
forvalues x = 1/17	 {
gen b`x' = s_RPI_`x'
drop if b`x' ==.
}
drop if I ==.
drop if I < 0

**quantile data*****
preserve
keep if percent != .
keep pp_value percent datayear
reshape wide pp_value, i(percent) j(datayear)
drop percent
outsheet using DataforMatlab\IP.csv, comma replace nonames
restore

gen logI = log(I)
gen logI2 = log(I)*log(I)
gen logI3 = log(I)*log(I)*log(I)
keep if I > 0
qui forvalues x = 1/17	 {
keep if b`x' <1 
keep if b`x' > -0.00001 
}

qui forvalues x = 1/17	 {
	reg b`x' logI  logI2  if datayear ==1974 , vce(robust)
	predict tmp if e(sample), xb 
	gen b`x'_hat = tmp
	drop tmp
}



qui forvalues t = 1975/2017 {

qui forvalues x = 1/17	 {
	reg b`x' logI  logI2  if datayear ==`t' , vce(robust)
	predict tmp if e(sample), xb 
	replace b`x'_hat = tmp if datayear == `t'
	drop tmp
}


  
}

keep datayear I b1_hat b2_hat b3_hat b4_hat b5_hat b6_hat b7_hat b8_hat b9_hat b10_hat b11_hat b12_hat b13_hat b14_hat b15_hat b16_hat b17_hat weight caseno
duplicates drop caseno datayear,force
drop caseno

outsheet using DataforMatlab\UK_Budget.csv, comma replace nonames
